package com.flx.at.spring.code.test.testbeanlifecycle.component;

import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Autowired;

import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;

/**
 * @Author: Fenglixiong
 * @Date: 2021/7/3 18:42
 * @Description:
 */
public class LifeCycleA implements InitializingBean {

    @Autowired
    private LifeCycleB lifeCycleB;

    public LifeCycleA(){
        System.out.println("LifeCycleA construct..."+lifeCycleB);
    }

    public void init(){
        System.out.println("LifeCycleA init..."+lifeCycleB);
    }

    public void destroy() throws Exception {
        System.out.println("LifeCycleA destroy..."+lifeCycleB);
    }

    @PostConstruct
    public void initPost(){
        System.out.println("LifeCycleA PostConstruct..."+lifeCycleB);
    }

    @PreDestroy
    public void destroyPre(){
        System.out.println("LifeCycleA PreDestroy..."+lifeCycleB);
    }

    @Override
    public void afterPropertiesSet() throws Exception {
        System.out.println("LifeCycleA afterPropertiesSet..."+lifeCycleB);
    }
}
